/*
 * shredder.h
 *
 *  Created on: 9 Oct 2012
 *      Author: michael
 */

#ifndef SHREDDER_H_
#define SHREDDER_H_

/*
 * Utility resources.
 */

//Return the size in bytes of a given file filename (const char *filename). Returns -1 for error.
int shredder_get_file_size(const char *filename);

//Check if we have write permissions on a given filename (const char *filename). Returns 1 for permissions, 0 for no permissons.
int shredder_have_write_permissions(const char *filename);


/*
 * Data generation resources
 */

typedef enum { SHREDDER_DATA_ZEROES, SHREDDER_DATA_ONES, SHREDDER_DATA_RANDOM } DataType;

#define SHREDDER_ALL_ONES '\377'

//Generate data of size (1 * size). Returns a char *, which should be free'd.
unsigned char *shredder_create_data(int size, DataType type);

/*
 * Iteration resources.
 */

typedef enum {
SHREDDER_FS_STAY_ON_FILE_SYSTEM_NO_SYMBOLIC_LINKS,
SHREDDER_FS_STAY_ON_FILE_SYSTEM,
SHREDDER_FS_NO_SYMBOLIC_LINKS,
SHREDDER_FS_NO_RESTRICTIONS
} ShredFSFlags;

//Recurse down given filename (const char *filename), calling function fn for every file unless fn return a non-zero value.
void shredder_recurse_folder(const char *filename, int (*fn)(const char *), ShredFSFlags flags);

/*
 * Shredding resources
 */

typedef enum { SHREDDER_SHRED_ZEROES, SHREDDER_SHRED_ONES, SHREDDER_SHRED_RANDOM } ShredType;

#define SHREDDER_MAX_FDS 10

//Shred a single file (cosnt char *filename) once, with the given ShredType.
int shredder_shred_single_file(const char *filename, ShredType type);

#endif /* SHREDDER_H_ */
